from networkFramework import *
from framework import *
from dataStruct import orderStruct as oStruct
import time


def main():
    
    configData = getOSConfig()
    
    if len(sys.argv) == 3:
        host = sys.argv[1]
        port = sys.argv[2]
    else:
        host = configData['host']
        port = configData['port']  
    
    configData = getConfig()
    timer = time.time()
    orderObj = oStruct()
    buffSize = orderObj.buffSize
    oRecSock = reciverUDPConn(host, port, buffSize)
    
    while True:
        orderObj.buffer = oRecSock.recData()
        try:
            out = orderObj.getValues()
            print out
        except:
            out = "Error: Timed out"
            print out
            #break
    
        if "EOF\x00" in out:
            break
    
    oRecSock.close()

if __name__ == "__main__":
    main()